package team.sun.sss.controller.log;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import team.sun.sss.dao.log.NotifyDao;

import java.util.List;
import java.util.Map;

@RestController
public class NotifyController {
    @Autowired
    NotifyDao notifyDao;

    @GetMapping("/NotifyList/{user_id}")
    public List<Map<String,Object>> NotifyList(@PathVariable int user_id){
        List<Map<String,Object>> NotifyList=notifyDao.getNotifyList(user_id);
        return NotifyList;
    }

    @GetMapping("/deleteNotify/{id_arr}")
    public String deleteNotify(@PathVariable String id_arr){
        try {
            notifyDao.deleteNotify(id_arr);
        }catch (Exception e){
            System.out.println(e);
            return "删除失败";
        }
        System.out.println("删除成功");
        return "删除成功";
    }

    @GetMapping("/updateNotify/{id_arr}")
    public String updateNotify(@PathVariable String id_arr){
        try {
            notifyDao.updateNotify(id_arr);
        }catch (Exception e){
            System.out.println(e);
            return "操作失败";
        }
        System.out.println("操作成功");
        return "操作成功";
    }

    @GetMapping("/updateNotify2/{id_arr}")
    public String updateNotify2(@PathVariable String id_arr){
        try {
            notifyDao.updateNotify2(id_arr);
        }catch (Exception e){
            System.out.println(e);
            return "操作失败";
        }
        System.out.println("操作成功");
        return "操作成功";
    }

}
